VPATH	= .

# Make sure the following five varaiables are set correctly

# Home directory of the acw program

# compiler specific flags
CFLAGS = -O3 -fbounds-check
# -heap-arrays -vec-report0
FFLAGS =  -llapack 
# Ususally, one doesn't need to bother with the rest of the makefile

PROJECT = elgmomc

INCLUDEDIR = include

LAPACKDIR = /usr/lib64

elgobj = mod_random.o mod_params.o derivs.o matter_power.o odeint.o rkqs.o lin_grow.o rkck.o shear_power.o
obj 	=  $(elgobj)  mod_matrix.o mod_lutil.o mod_elglike_element.o mod_elgdata.o mod_elglike.o mod_elgmc.o mod_likelihood.o mod_myelg.o

FC90 	= mpif90

default: $(PROJECT)

$(PROJECT): $(PROJECT).o  $(obj) 
	$(FC90) -L$(INCLUDEDIR) -L$(LAPACKDIR)  -o $(PROJECT) $(PROJECT).o $(obj) $(FFLAGS)  

$(PROJECT).o: $(PROJECT).f90  $(obj)
	$(FC90) $(CFLAGS)  -I$(INCLUDEDIR)  -c $(PROJECT).f90 

myelg: myelg.o $(obj)
	$(FC90) -L$(INCLUDEDIR) -L$(LAPACKDIR)  -o myelg myelg.o $(obj) $(FFLAGS)  

myelg.o: myelg.f90  $(obj)
	$(FC90) $(CFLAGS)  -I$(INCLUDEDIR)  -c myelg.f90 



mod_matrix.o: $(INCLUDEDIR)/mod_matrix.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_matrix.f90

mod_lutil.o: $(INCLUDEDIR)/mod_lutil.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_lutil.f90

mod_elgmc.o: $(INCLUDEDIR)/mod_elgmc.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_elgmc.f90

mod_likelihood.o: $(INCLUDEDIR)/mod_likelihood.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_likelihood.f90

mod_elglike.o: $(INCLUDEDIR)/mod_elglike.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_elglike.f90

mod_myelg.o: $(INCLUDEDIR)/mod_myelg.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_myelg.f90

mod_elgdata.o: $(INCLUDEDIR)/mod_elgdata.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_elgdata.f90

mod_elglike_element.o: $(INCLUDEDIR)/mod_elglike_element.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_elglike_element.f90

derivs.o: $(INCLUDEDIR)/derivs.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/derivs.f90

matter_power.o: $(INCLUDEDIR)/matter_power.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/matter_power.f90

odeint.o: $(INCLUDEDIR)/odeint.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/odeint.f90

rkqs.o: $(INCLUDEDIR)/rkqs.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/rkqs.f90

lin_grow.o: $(INCLUDEDIR)/lin_grow.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/lin_grow.f90

rkck.o: $(INCLUDEDIR)/rkck.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/rkck.f90

shear_power.o: $(INCLUDEDIR)/shear_power.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/shear_power.f90

mod_params.o: $(INCLUDEDIR)/mod_params.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_params.f90

mod_random.o: $(INCLUDEDIR)/mod_random.f90
	$(FC90) $(CFLAGS)  -c  $(INCLUDEDIR)/mod_random.f90

clean:	
	rm *.mod *.o elgmomc

simulate:	
$(PROJECT):  $(PROJECT).o  $(obj) 
	$(FC90)  -L$(INCLUDEDIR) -L$(LAPACKDIR) -o $(PROJECT) $(PROJECT).o $(obj) $(FFLAGS)  

$(PROJECT).o: $(PROJECT).f90  $(obj)
	$(FC90) $(CFLAGS)  -I$(INCLUDEDIR)  -c $(PROJECT).f90 


